<?php
namespace \Absidon\Controller\Uri;
/**
 * Rewrite URI class for parsing the path from a true pretty uri.
 *
 * The rewrite URI structure does not have index.php and allows for mod_rewrite and systems like
 * apache mod_rewrite to parse uris for the application. The code for supporting those systems is
 * not implemented here. It can be done manually, if you know how or you can use a class or
 * component that creates the code for you to copy and paste.
 *
 * If you wish to have one of the query vars to be a directory like structure, then that is
 * supported as this class is not going to confuse any URI that does not include index.php with
 * being the {@link Absidon\Controller\Uri\Pathinfo} uri type.
 *
 * Example: /controller/action?query=var
 * Example: /controller/action/subcontroller/subaction
 *
 * @author Jacob Santos <webmaster@absidongames.com>
 * @since 0.1
 * @package Absidon
 * @subpackage Controller_Uri
 * @license Simplified BSD License <http://www.opensource.org/licenses/bsd-license.html>
 * @license GNU Lesser General Public License 2.1 or later <http://www.opensource.org/licenses/lgpl-2.1.php>
 */

/**
 * Pathinfo URI class for parsing the path from a query var.
 *
 * The class tests to see if the URI structure appears to be using Pathinfo. It does this by
 * checking for index.php and a directory structure in the URI. By default, the router will attempt
 * to auto find the correct class and does so by first calling each classes {@link Pathinfo::test()}
 * method.
 *
 * The class will match against the PathInfo structure for a location and return either true or an
 * array for options based on the match.
 *
 * This class is not for calling controllers, that is the routers job. This class should also not be
 * used by the application as it is an internal library component.
 */
class Rewrite implements Uri_Component, Pretty_Uri_Component
{
	/**
	 * Whether the rewrite pretty URI is being used.
	 *
	 * @since 0.1
	 * @see Absidon\Controller\Uri\uri_component::is_used() Implemented.
	 * @todo This needs to replace the base uri to make sure index.php is not at the end.
	 *
	 * @return boolean
	 */
	public function is_used()
	{
		return ( stripos('/index.php', get_uri_request()) === false || preg_match('/[a-z]+\.php\?\/.*?\/?/i', get_uri_request()) == false );
	}

	/**
	 * @since 0.1
	 * @see Absidon\Controller\Uri\uri_component::process_uri() Implemented.
	 */
	public function process_uri()
	{
		//
	}

	/**
	 * @since 0.1
	 * @see Absidon\Controller\Uri\pretty_uri_component::match() Implemented.
	 *
	 * @param string $regex
	 * @returns bool|array
	 */
	public function match($regex)
	{
		/** @todo complete. */
	}
}